home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of Mid --->
- <HTML>
- <HEAD>
- <TITLE>Mid Example</TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
- <H3>Mid Example</H3>
-
- <CFIF IsDefined("Form.MyText")>
- <!--- if len is 0, then err --->
- <CFIF Len(form.myText) is not 0>
- <CFIF Len(form.myText) LTE form.RemoveChars>
- <P>Your string <CFOUTPUT>#form.myText#</cFOUTPUT>
- only has <CFOUTPUT>#Len(form.myText)#</cFOUTPUT>
- characters. You cannot output the <CFOUTPUT>#form.removeChars#</cFOUTPUT>
- middle characters of this string because it is not long enough
- <CFELSE>
-
- <P>Your original string: <CFOUTPUT>#form.myText#</CFOUTPUT>
- <P>Your changed string, showing only the <CFOUTPUT>#form.removeChars#</CFOUTPUT> middle characters:
- <CFOUTPUT>#Mid(Form.myText, Form.countChars, form.removeChars)#</CFOUTPUT>
- </CFIF>
- <CFELSE>
- <P>Please enter a string
- </CFIF>
- </CFIF>
-
- <FORM ACTION="mid.cfm" METHOD="POST">
- <P>Type in some text
- <BR><INPUT TYPE="Text" NAME="MyText">
- <P>How many characters you want to return?
- <SELECT NAME="RemoveChars">
- <OPTION VALUE="1">1
- <OPTION VALUE="3" SELECTED>3
- <OPTION VALUE="5">5
- <OPTION VALUE="7">7
- <OPTION VALUE="9">9</SELECT>
-
- <P>At what position do you want to start?
- <SELECT NAME="countChars">
- <OPTION VALUE="1">1
- <OPTION VALUE="3" SELECTED>3
- <OPTION VALUE="5">5
- <OPTION VALUE="7">7
- <OPTION VALUE="9">9</SELECT>
- <INPUT TYPE="Submit" NAME="Remove characters">
- </FORM>
-
- </BODY>
- </HTML>
-